<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%--
  Created by IntelliJ IDEA.
  User: ye
  Date: 2020/2/27
  Time: 16:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>医院查询</title>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/static/css/style1.css" />

    <link rel="stylesheet" type="text/css"
          href="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/css/bootstrap.min.css" />

    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/js/bootbox.min.js"></script>
    <style>
        /*.page {*/
            /*font-family: Arial, "楷体";*/
            /*font-size: 15px;*/
            /*line-height: 26px;*/
            /*color: #000000;*/
            /*height: 40px;*/
            /*margin-top: -15px;*/
            /*background-color: #EEF6FF;*/
            /*margin-right: 0;*/
        /*}*/

        /*.page td {*/
            /*padding-right: 10px;*/
            /*padding-left: 10px;*/
        /*}*/

        /*.page select {*/
            /*font-family: Arial, "楷体";*/
            /*font-size: 12px;*/
            /*color: #000000;*/
            /*line-height: 18px;*/
            /*border: 1.5px solid #5084BB;*/
        /*}*/
    </style>
</head>
<style>
    table {
        border-spacing: 1px;
        width: 50%;
        border: 1px solid blue;
    }

    td {
        border: 1px solid blue;
    }


</style>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
    function doHospitalModify(hospital_id) {
        var data={
            "hospital_id":hospital_id

        }
        $.ajax({
            url:"/hospitalById",
            type : "post",
            data: JSON.stringify(data),
            success:function (hospital) {
                $("#hospital_id").val(hospital.hospital_id);
                $("#hospital_name").val(hospital.hospital_name);
                $("#hospital_site").val(hospital.hospital_site);
                $("#hospital_area").val(hospital.hospital_area);
            },
            dataType: "json",
            contentType: "application/json"
        })
    }


    function openwin() {
        window.open('insertHospital.jsp', '新增', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
    }

</script>
<body>
<input type="button" onclick="openwin()" value="新增"><br>
<form action="/hospitalBy">
    <input type="text" id="text" name="text">
    <input type="submit">
</form>
<table>
    <tr>
        <td>id编号</td>
        <td>医院名字</td>
        <td>医院地址</td>
        <td>所属分区</td>
        <td>操作</td>
    </tr>


    <c:forEach items="${hospital}" var="h">
        <tr>
            <td >${h.hospital_id}</td>
            <td >${h.hospital_name}</td>
            <td >${h.hospital_site}</td>
            <td >${h.area_name}</td>
            <td><div class="edit2">
                <span id ="edit1" class="edit1" data-toggle="modal" data-target="#renyuan1" style="color:#479eff;cursor: pointer;" onclick="doHospitalModify(${h.hospital_id})">编辑</span>
                <div class="modal fade" id="renyuan1">
                    <div class="modal-dialog modal-lg modal_position">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title">编辑</h4>
                                <button type="button" class="close" data-dismiss="modal">&times;</button>
                            </div>
                            <form id="form2" name="form2" action="/hospitalUpdate" >
                                <div class="modal-body">
                                    <table id="xztb" class="table" >
                                        <tbody>
                                        <tr>
                                            <td class="tb_bg"><label for=""><font
                                                    style="font-size: 14px; color: red;">*</font>医院ID：</label></td>
                                            <td><input class="hospital_id" type="text"
                                                       name="hospital_id" id="hospital_id" value="${hospital_id }"/></td>
                                        </tr>
                                        <tr>
                                            <td class="tb_bg"><label for=""><font
                                                    style="font-size: 14px; color: red;">*</font>医院名字：</label></td>
                                            <td><input class="hospital_name" type="text"
                                                       name="hospital_name" id="hospital_name" value="${hospital_name }"/></td>
                                        </tr>
                                        <tr>
                                            <td class="tb_bg"><label for=""><font
                                                    style="font-size: 14px; color: red;">*</font>医院地址</label></td>
                                            <td><input class="hospital_site" type="text"
                                                       name="hospital_site" id="hospital_site" value="${hospital_site }"/></td>
                                        </tr>
                                        <tr>
                                            <td class="tb_bg"><label for=""><font
                                                    style="font-size: 14px; color: red;">*</font>医院地区</label></td>
                                            <td><input type="text" name="hospital_area" id="hospital_area" value="${hospital_area }"/></td>
                                        </tr>

                                        </tbody>
                                    </table>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-secondary"
                                                data-dismiss="modal" style="background: white">取消</button>
                                        <button id="ad_btn" type="submit" class="btn btn-secondary" >确定</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                </div><a href="hospitalDelete?id=${h.hospital_id}">删除</a>
            </td>
        </tr>
    </c:forEach>
    <c:forEach items="${hospital1}" var="h1">
        <tr>
            <td>${h1.hospital_id}</td>
            <td>${h1.hospital_name}</td>
            <td>${h1.hospital_site}</td>
            <td>${h1.area_name}</td>
            <td>
                <a href="#" onclick="bianji()">编辑</a>
                <a href="hospitalDelete?id=${h1.hospital_id}">删除</a>
            </td>
        </tr>


    </c:forEach>
</table>
</body>
</html>
